package cn.ekuma.epos.crm;

import java.util.Date;
import java.util.Properties;

import com.openbravo.bean.crm.CustomerAddress;
import com.openbravo.data.basic.BasicException;
import com.openbravo.data.user.DirtyManager;
import com.openbravo.pos.base.AppLocal;
import com.openbravo.pos.panels.shard.AddressEditor;

import cn.ekuma.data.ui.swing.AbstractChildDAOJEditor;
import java.awt.BorderLayout;

public class CustomerAddressEditor extends AbstractChildDAOJEditor< CustomerAddress,String>{

	AddressEditor addressEditor;
	
	public CustomerAddressEditor(DirtyManager dirty) {
		super(dirty);
		addressEditor=new AddressEditor(dirty);
		initComponents();
	}
	private void initComponents() {
		setLayout(new BorderLayout(0, 0));
		add(addressEditor,BorderLayout.CENTER);
	}

	@Override
	public String getTabName() {
		return AppLocal.getIntString("label.CustomerAddress");
	}

	@Override
	public void refresh() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public CustomerAddress createNew(Properties prop) {
		CustomerAddress newObj=new CustomerAddress();
		newObj.setCreateDate(new Date());
		if(parentNode!=null)
            newObj.setCustomerId(parentNode.getParentKey().getKey());
		return newObj;
	}

	@Override
	public void rebuild(CustomerAddress obj) throws BasicException {
		addressEditor.rebuild(obj);
		
	}

	@Override
	public void updateUI(boolean editAble, int state) {	
	}

	@Override
	public Class getEditClass() {
		return CustomerAddress.class;
	}
	
	@Override
	public void writeValueInsert(Properties prop) {
		super.writeValueInsert(prop);
		addressEditor.writeValueInsert(prop);
	}
	@Override
	public void writeValueDelete(CustomerAddress value) {
		super.writeValueDelete(value);
		addressEditor.writeValueDelete(value);
	}
	@Override
	public void writeValueEOF() {
		super.writeValueEOF();
		addressEditor.writeValueEOF();
	}
	@Override
	public void writeValueEdit(CustomerAddress value) {
		super.writeValueEdit(value);
		addressEditor.writeValueEdit(value);
	}

}
